﻿using PacketDotNet.Utils;
using SharpPcap;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading.Tasks;

namespace Services.Equ.PcapCommunication.Abstract
{
    /// <summary>
    /// pcap通讯写入操作基类
    /// </summary>
    public abstract class AbstractPcapWriteCommunication : AbstractPcapCommunication<bool>
    {
        protected AbstractPcapWriteCommunication(PhysicalAddress destinationMac, string password, ILiveDevice device) : base(destinationMac, password, device)
        {
            ReciveBreak = 1;
        }
        public override bool IsResponse(byte[] bytes)
        {
            if (bytes.Length >= 96)
            {
                if (base.IsResponse(bytes))
                {
                    if (bytes[77] == 4 && (bytes[79] == 5 || bytes[79] == 6))
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
                return false;
            }
            return false;

        }

        public override bool ConvertData2Result(byte[] bytes)
        {
            return bytes[79] == 5;
        }
    }
}
